# coding=utf-8

"""
    Created by Kalyter on 2017-11-16.
"""


def split_string(content, step):
    result = set()
    for i in range(step, len(content) + 1):
        result.add(content[i - step: i])
    return result


def jaccard(a, b, step):
    a = split_string(a, step)
    b = split_string(b, step)
    t = [v for v in a if v in b]
    c = set()
    [c.add(i) for i in t]
    return float(len(c))/(len(a)+len(b)-len(c))


def compare_by_jaccard(x, y, step=5):
    return jaccard(x, y, step)
